package com.javafamily.service;

import com.javafamily.bean.Pets;
import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

// 服务降级类
@Component
public class PetsFallbackFactory implements FallbackFactory<PetService> {
    @Override
    public PetService create(Throwable cause) {
        return new PetService() {
            @Override
            public boolean savePets(Pets pets) {
                System.out.println("savePets");
                return false;
            }

            @Override
            public boolean removePetsById(Integer id) {
                System.out.println("removePets");
                return false;
            }

            @Override
            public boolean modifyPets(Pets pets) {
                System.out.println("modifyPets");
                return false;
            }

            @Override
            public Pets getPetsById(Integer id) {
                System.out.println("getPets");
                Pets pets1 = new Pets();
                pets1.setId(id);
                pets1.setName("get pets failed--Factory");
                return pets1;
            }

            @Override
            public List<Pets> listAllPets() {
                System.out.println("listAll");
                return null;
            }

        };
    }
}